import Vue from 'vue'

Vue.filter('numToCN', function(value) {
  const CN = [...'零一二三四五六七八九']
  const type = typeof value
  if (['string', 'number'].includes(type)) {
    const strVal = `${value}`
    return [...strVal].map(char => {
      return CN[char]
    }).join('')
  }
  return ''
})

Vue.filter('severityToLevel', function(value) {
  const val = Number(value)
  switch (val) {
    case 5:
      return '一级';
    case 3:
      return '三级';
    case 2:
      return '二级';
    default:
      return '-'
  }
})

Vue.filter('arrayToStr', function(array) {
  if (array) {
    return array.join('，')
  } else {
    return '-'
  }
})
